home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MACD 5
/
MACD 5.bin
/
workbench
/
blankery
/
bserverdir
/
sources
/
server
/
modeid.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-11-29
|
3KB
|
128 lines
#include <exec/memory.h>
#include <graphics/displayinfo.h>
#include <graphics/modeid.h>
#include "/include/server.h"
#include <clib/alib_protos.h>
#include <clib/exec_protos.h>
#include <clib/graphics_protos.h>
#include <string.h>
struct List *ModeList;
struct ModeNode *DisplayNode;
ULONG DisplayID = PAL_MONITOR_ID;
char DefaultModeName[DISPLAYNAMELEN];
void DeleteModeList( void )
{
struct ModeNode *ModeNode;
while (ModeList->lh_Head->ln_Succ)
{
ModeNode=(struct ModeNode *)ModeList->lh_Head;
RemHead (ModeList);
FreeVec( ModeNode );
}
FreeVec( ModeList );
}
struct List *CreateModeList(void)
{
UWORD Index = 0;
ULONG NewDisplID;
struct DimensionInfo DimInfo;
struct NameInfo NameInfo;
struct ModeNode *NewNode;
if ( ModeList = AllocVec( sizeof(struct List), MEMF_PUBLIC ) )
NewList( ModeList );
else
return( NULL );
NewDisplID=INVALID_ID;
while ( ( NewDisplID = NextDisplayInfo( NewDisplID ) ) != INVALID_ID )
if ( ( NewDisplID & MONITOR_ID_MASK ) && ( !ModeNotAvailable( NewDisplID ) ) )
if ( GetDisplayInfoData( NULL, (UBYTE *)&DimInfo, sizeof(struct DimensionInfo), DTAG_DIMS, NewDisplID ) )
if ( GetDisplayInfoData( NULL, (UBYTE *)&NameInfo, sizeof(struct NameInfo), DTAG_NAME, NewDisplID ) )
if ( NewNode = AllocVec( sizeof(struct ModeNode), MEMF_CLEAR ) )
{
NewNode->mn_Node.ln_Name = NewNode->mn_Name;
NewNode->mn_DisplayID = NewDisplID;
NewNode->mn_Index = Index++;
strcpy( NewNode->mn_Name, NameInfo.Name );
AddTail( ModeList, (struct Node *)NewNode );
}
if ( !(ModeList->lh_Head->ln_Succ) )
{
FreeMem( ModeList, sizeof(struct List) );
return( NULL );
}
if ( DisplayID == INVALID_ID )
{
if ( NewNode = (struct ModeNode *)FindName( ModeList, DefaultModeName ) )
DisplayID = NewNode->mn_DisplayID;
else
DisplayID = PAL_MONITOR_ID;
}
return( ModeList );
}
void GetDisplayNodeFromID( void )
{
DisplayNode = (struct ModeNode *)ModeList->lh_Head;
while( DisplayNode && DisplayNode->mn_DisplayID != DisplayID )
DisplayNode = (struct ModeNode *)DisplayNode->mn_Node.ln_Succ;
if ( !DisplayID || !DisplayNode )
{
DisplayNode = (struct ModeNode *)ModeList->lh_Head;
DisplayID = DisplayNode->mn_DisplayID;
}
}
void GetDisplayNodeFromName( void )
{
if ( (*DefaultModeName != 0) && (DisplayNode = (struct ModeNode *)FindName( ModeList, DefaultModeName )) )
DisplayID = DisplayNode->mn_DisplayID;
else
DisplayID = PAL_MONITOR_ID;
}
void GetDisplayIDFromNode( UWORD Index )
{
DisplayNode = (struct ModeNode *)ModeList->lh_Head;
while( DisplayNode && DisplayNode->mn_Index != Index )
DisplayNode = (struct ModeNode *)DisplayNode->mn_Node.ln_Succ;
DisplayID = DisplayNode->mn_DisplayID;
}
struct DisplayIDInformation *AllocDisplayIDInformation( ULONG whichDisplayID )
{
struct DisplayIDInformation *diinfo;
if ( diinfo = AllocVec( sizeof(struct DisplayIDInformation), MEMF_PUBLIC ) )
{
if ( GetDisplayInfoData( NULL, (UBYTE *)&diinfo->di_DisplayInfo, sizeof(struct DisplayInfo), DTAG_DISP, whichDisplayID ) )
if ( GetDisplayInfoData( NULL, (UBYTE *)&diinfo->di_DimensionInfo, sizeof(struct DimensionInfo), DTAG_DIMS, whichDisplayID ) )
if ( GetDisplayInfoData( NULL, (UBYTE *)&diinfo->di_MonitorInfo, sizeof(struct MonitorInfo), DTAG_MNTR, whichDisplayID ) )
return( diinfo );
FreeVec( diinfo );
}
return( NULL );
}